home *** CD-ROM | disk | FTP | other *** search
- /*
- File: ShapeCommands.h
-
- Contains: Shape command Classes Definition
-
- Written by: Dave Stafford
-
- Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
- */
-
- #ifndef _SHAPECOMMANDS_
- #define _SHAPECOMMANDS_
-
- // -- DrawEditor Includes --
-
- #ifndef _COMPILERDEFS_
- #include "CompDefs.h"
- #endif
-
- #ifndef _DRAWEDITORCONSTANTS_
- #include "DrawEditorConstants.h"
- #endif
-
- #ifndef _COMMAND_
- #include "Command.h"
- #endif
-
- #ifndef _DRAWEDITORDEF_
- #include "DrawEditorDef.h"
- #endif
-
- #ifndef _PALETTE_
- #include "Palette.h"
- #endif
-
- //=============================================================================
- // Constants
- //=============================================================================
- const ODPropertyName kPropFrameInfo = "SampleCode:Property:FrameInfo";
- const ODPropertyName kPropMouseDownOffset = "SampleCode:Property:MouseDownLoc";
- const ODValueType kODPointValue = "Sample:ValueType:ODPoint";
-
-
- //=============================================================================
- // Forward Declarations
- //=============================================================================
- class DrawEditor;
- class CShape;
- class ODFacet;
- class CSelection;
- class COrderedList;
- class ODDragItemIterator;
- class CSubscribeLink;
- class CPublishLink;
-
- //=============================================================================
- // CModifySelectionCommand
- //=============================================================================
- class CModifySelectionCommand : public CCommand
- {
- public:
- // -- Init --
- CModifySelectionCommand(DrawEditor* theEditor,
- CSelection* selection,
- ODBoolean canUndo = kODFalse,
- ODBoolean changesContent = kODFalse,
- ODID undoTextIndex = kUndoCommandIndex,
- ODID redoTextIndex = kRedoCommandIndex);
-
- virtual ~CModifySelectionCommand();
-
- // -- Inherited API --
- virtual void CaptureCommandState(Environment* ev);
- virtual void UndoCommand(Environment* ev);
- virtual void RedoCommand(Environment* ev);
-
- // -- New API --
- void SelectModifiedShapes(Environment* ev);
- public:
-
- CSelection* fSelection;
- COrderedList* fSubscribeLinks;
- COrderedList* fSavedShapes;
- };
-
-
- //=============================================================================
- // CResizeSelectionCommand
- //=============================================================================
- class CResizeSelectionCommand : public CModifySelectionCommand
- {
- public:
-
- // -- Init --
- CResizeSelectionCommand(DrawEditor* theEditor,
- ODFacet* sourceFacet,
- CSelection* selection,
- Rect& baseRect,
- Rect& resizeRect);
-
- virtual ~CResizeSelectionCommand();
-
- public:
-
- // Undo-able commands
- // Should call inherited in derivative classes
- virtual void UndoCommand(Environment* ev);
- virtual void RedoCommand(Environment* ev);
-
- // Is called from DoCommand. Used to store information
- // about the command ( shapelists, etc. ).
- virtual void CaptureCommandState(Environment* ev);
-
- // Called just before the command is deleted.
- // Default does nothing
- virtual void Commit(Environment* ev, ODDoneState state);
-
- // -- Must Override this method --
- // This method should only be called once per instance
- // Should call inherited in derivative classes
- virtual void DoCommand(Environment* ev);
-
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- private:
- Rect fBaseRect;
- Rect fResizeRect;
-
- ODFacet* fSourceFacet;
- };
-
-
-
-
- //=============================================================================
- // CNewShapeCommand
- //=============================================================================
- class CNewShapeCommand : public CCommand
- {
- public:
-
- // -- Init --
- CNewShapeCommand(DrawEditor* theEditor,
- ODFacet* sourceFacet,
- Rect& bounds,
- CRGBColor& color,
- ODSShort shapeType,
- CSelection* selection);
-
- virtual ~CNewShapeCommand();
-
- public:
-
- // Undo-able commands
- // Should call inherited in derivative classes
- virtual void UndoCommand(Environment* ev);
- virtual void RedoCommand(Environment* ev);
-
- // Is called from DoCommand. Used to store information
- // about the command ( shapelists, etc. ).
- virtual void CaptureCommandState(Environment* ev);
-
- // Called just before the command is deleted.
- // Default does nothing
- virtual void Commit(Environment* ev, ODDoneState state);
-
- // -- Must Override this method --
- // This method should only be called once per instance
- // Should call inherited in derivative classes
- virtual void DoCommand(Environment* ev);
-
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- private:
- CRGBColor fShapeColor;
- ODSShort fShapeType;
- Rect fShapeBounds;
- CShape* fShape;
- CSelection* fSelection;
- ODFacet* fSourceFacet;
- };
-
-
- //=============================================================================
- // CMoveShapeCommand
- //
- // The move shape command actually handles the 4 shape move
- // commands: MoveForward, MoveFront, MoveBackward, and MoveBack
- //=============================================================================
- class CMoveShapeCommand : public CCommand
- {
- public:
-
- // -- Init --
- CMoveShapeCommand(DrawEditor* theEditor,
- ODFrame* sourceFrame,
- ODCommandID moveType,
- CSelection* selection);
-
- virtual ~CMoveShapeCommand();
-
- public:
-
- // Undo-able commands
- // Should call inherited in derivative classes
- virtual void UndoCommand(Environment* ev);
- virtual void RedoCommand(Environment* ev);
-
- // Is called from DoCommand. Used to store information
- // about the command ( shapelists, etc. ).
- virtual void CaptureCommandState(Environment* ev);
-
- // Called just before the command is deleted.
- // Default does nothing
- virtual void Commit(Environment* ev, ODDoneState state);
-
- // -- Must Override this method --
- // This method should only be called once per instance
- // Should call inherited in derivative classes
- virtual void DoCommand(Environment* ev);
-
- // New API
- void MoveShape(Environment* ev, CShape* moveShape, CShape* shape);
- CShape* FindReferenceShape(Environment* ev, CShape* moveShape);
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- private:
- ODCommandID fMoveType;
- ODFrame* fSourceFrame;
- CSelection* fSelection;
- COrderedList* fSavedShapes;
- };
-
-
- //=============================================================================
- // CColorSelectionCommand
- //=============================================================================
- class CColorSelectionCommand : public CCommand
- {
- public:
-
- // -- Init --
- CColorSelectionCommand(DrawEditor* theEditor,
- CSelection* selection,
- CRGBColor& newColor);
-
- virtual ~CColorSelectionCommand();
-
- public:
-
- // Undo-able commands
- // Should call inherited in derivative classes
- virtual void UndoCommand(Environment* ev);
- virtual void RedoCommand(Environment* ev);
-
- // Is called from DoCommand. Used to store information
- // about the command ( shapelists, etc. ).
- virtual void CaptureCommandState(Environment* ev);
-
- // Called just before the command is deleted.
- // Default does nothing
- virtual void Commit(Environment* ev, ODDoneState state);
-
- // -- Must Override this method --
- // This method should only be called once per instance
- // Should call inherited in derivative classes
- virtual void DoCommand(Environment* ev);
-
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- private:
- CRGBColor fColor;
-
- COrderedList* fSavedColors;
- CSelection* fSelection;
- };
-
-
-
- //=============================================================================
- // CDragShapeCommand
- //=============================================================================
- class CDragShapeCommand : public CCommand
- {
- public:
-
- // -- Init --
- CDragShapeCommand(DrawEditor* theEditor,
- ODFacet* sourceFacet,
- CSelection* selection,
- ODEventData* event,
- ODBoolean showFeedBack,
- ODBoolean canUndo = kODTrue);
-
- virtual ~CDragShapeCommand();
-
- public:
-
- // Undo-able commands
- // Should call inherited in derivative classes
- virtual void UndoCommand(Environment* ev);
- virtual void RedoCommand(Environment* ev);
-
- // Is called from DoCommand. Used to store information
- // about the command ( shapelists, etc. ).
- virtual void CaptureCommandState(Environment* ev);
-
- // Called just before the command is deleted.
- // Default does nothing
- virtual void Commit(Environment* ev, ODDoneState state);
-
- // -- Must Override this method --
- // This method should only be called once per instance
- // Should call inherited in derivative classes
- virtual void DoCommand(Environment* ev);
-
- // New API ( Drag Stuff )
- ODBoolean Drag(Environment* ev, ODEventData* event);
- void DragCompleted(Environment* ev);
- ODShape* CreateDragShape(Environment* ev, ODFacet* facet);
- void SelectDraggedShapes(Environment* ev);
- void CreateLink(Environment* ev, CPublishLink* pLink);
-
-
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- private:
-
- ODEventData* fEventData;
- ODBoolean fShowDragFeedback;
- CSelection* fSelection;
- COrderedList* fSavedShapes;
- COrderedList* fPublishLinks;
- COrderedList* fSubscribeLinks;
-
- ODRgnHandle fDragRegion;
- ODDragResult fDragResult;
- ODFacet* fSourceFacet;
-
- ODPart* fDestinationPart;
- CPublishLink* fPublishLink;
-
- ODBoolean fTransactionClosed;
- };
-
-
- //=============================================================================
- // CDropShapeCommand
- //=============================================================================
- class CDropShapeCommand : public CCommand
- {
- public:
- // -- Init --
- CDropShapeCommand(DrawEditor* theEditor,
- ODFacet* sourceFacet,
- ODDragItemIterator* dropInfo,
- CSelection* selection,
- ODPoint& dropPoint,
- ODBoolean canUndo = kODTrue);
-
- virtual ~CDropShapeCommand();
-
- // -- Accessors --
- ODDropResult GetDropResult();
-
- // Undo-able commands
- // Should call inherited in derivative classes
- virtual void UndoCommand(Environment* ev);
- virtual void RedoCommand(Environment* ev);
-
- // Is called from DoCommand. Used to store information
- // about the command ( shapelists, etc. ).
- virtual void CaptureCommandState(Environment* ev);
-
- // Called just before the command is deleted.
- // Default does nothing
- virtual void Commit(Environment* ev, ODDoneState state);
-
- // -- Must Override this method --
- // This method should only be called once per instance
- // Should call inherited in derivative classes
- virtual void DoCommand(Environment* ev);
-
- // -- New API ( Drop Stuff ) --
-
- // Check the drop result, and cancel Undo if the drop failed.
- void AdjustUndo(Environment* ev);
-
- // Return non-zero value if the source part was moved;
- void GetDropOrigin(Environment* ev, ODPoint* originPoint);
-
- // Drop methods
- virtual void ExecuteDrop(Environment* ev);
-
- ODBoolean DoDroppedInSameFrame(Environment* ev,
- ODStorageUnit* dropSU,
- ODPoint& mouseOffset,
- ODPoint& dropPoint);
-
- void SelectDroppedShapes(Environment* ev);
-
-
- protected:
- CSelection* fSelection;
- ODFacet* fSourceFacet;
-
- ODDropResult fDropResult;
- ODBoolean fDroppedInSameFrame;
- ODDragItemIterator* fDropInfo;
-
- ODPoint fDropPoint;
- ODPoint fDropOffset;
-
- COrderedList* fSavedShapes;
- COrderedList* fPublishLinks;
- COrderedList* fSubscribeLinks;
-
- };
-
-
- //=============================================================================
- // CDropAsCommand
- //=============================================================================
- class CDropAsCommand : public CDropShapeCommand
- {
- public:
- // -- Init --
- CDropAsCommand(DrawEditor* theEditor,
- ODFacet* sourceFacet,
- ODDragItemIterator* dropInfo,
- CSelection* selection,
- ODPoint& dropPoint,
- ODBoolean doEmbed);
-
- virtual ~CDropAsCommand();
-
- // Drop methods
- void ExecuteDrop(Environment* ev);
-
-
- private:
- // True for embed, false for merge
- ODBoolean fDoEmbed;
-
- };
-
-
- //=============================================================================
- // CCutCopyClearShapeCommand
- //=============================================================================
- class CCutCopyClearShapeCommand : public CCommand
- {
- public:
-
- // -- Init --
- CCutCopyClearShapeCommand(DrawEditor* theEditor,
- ODFrame* sourceFrame,
- CSelection* selection,
- ODCommandID command);
-
- virtual ~CCutCopyClearShapeCommand();
-
- public:
-
- // Inherited API
- virtual void UndoCommand(Environment* ev);
- virtual void RedoCommand(Environment* ev);
- virtual void CaptureCommandState(Environment* ev);
- virtual void Commit(Environment* ev, ODDoneState state);
- virtual void DoCommand(Environment* ev);
-
- // New API ( Cut / Copy Stuff )
- void SelectCutShapes(Environment* ev);
- void WriteShapesToClipboard(Environment* ev);
-
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- private:
-
- ODFrame* fSourceFrame;
- CSelection* fSelection;
-
- ODCloneKind fCloneKind;
- ODUpdateID fUpdateID;
- ODCommandID fCommandID;
- COrderedList* fSavedShapes;
- COrderedList* fPublishLinks;
- COrderedList* fSubscribeLinks;
-
- };
-
-
- //=============================================================================
- // CPasteCommand
- //=============================================================================
- class CPasteCommand : public CCommand
- {
- public:
- // -- Init --
- CPasteCommand(DrawEditor* theEditor,
- ODFrame* sourceFrame,
- CSelection* selection);
-
- virtual ~CPasteCommand();
-
- // -- Inherited API --
- virtual void DoCommand(Environment* ev);
- virtual void UndoCommand(Environment* ev);
- virtual void RedoCommand(Environment* ev);
-
- virtual void CaptureCommandState(Environment* ev);
- virtual void Commit(Environment* ev, ODDoneState state);
-
- // -- New API ( Paste Stuff ) --
-
- // Paste methods
- virtual void HandlePaste(Environment* ev);
- void SelectPastedShapes(Environment* ev);
-
- protected:
- CSelection* fSelection;
- ODFrame* fSourceFrame;
- ODUpdateID fUpdateID;
-
- COrderedList* fSavedShapes;
- COrderedList* fPublishLinks;
- COrderedList* fSubscribeLinks;
- };
-
- //=============================================================================
- // CPasteAsCommand
- // This class was created to extend the functionality of the past command
- // to include forcing a merge or embed based on the result of the paste as
- // dialog. This command does not include any support for translation of kinds
- // since this part only supports one kind. If any support for translation on
- // paste as were to be added, it could be done here as well.
- //=============================================================================
- class CPasteAsCommand : public CPasteCommand
- {
- public:
- // -- Init --
- CPasteAsCommand(DrawEditor* theEditor,
- ODFrame* sourceFrame,
- CSelection* selection,
- ODBoolean embedOrMerge);
-
- virtual ~CPasteAsCommand();
-
- // -- Inherited API --
- virtual void HandlePaste(Environment* ev);
-
- private:
- // True for embed, false for merge
- ODBoolean fDoEmbed;
- };
-
-
- #endif
-
-
-